import mapboxgl from 'mapbox-gl';
class Popup {
    map
    popup
    constructor(options, map) {
        let opt = {
            anchor: 'bottom',
            className: 'my-popup',
            closeButton: true,
            closeOnMove: false,
            focusAfterOpen: true,
            maxWidth: '200px',
            offset: new mapboxgl.Point(0,-35)
        }
        Object.assign(opt, options)
        this.map = map
        this.popup = new mapboxgl.Popup(opt)
    }
    setPopup(point, dom) {
        if (dom) {
            this.popup.setHTML(dom)
        }
        this.popup.setLngLat(point).addTo(this.map)
    }
    remove() {
        this.popup.remove()
    }
    setText(text) {
        this.popup.setText(text)
    }
    setHtml(html) {
        this.popup.setHTML(html)
    }
    setDom(dom) {
        this.popup.setDOMContent(dom)
    }
}

export default Popup
